<!doctype html>
<!--[if lt IE 7 ]> <html lang="ja" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]>    <html lang="ja" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>    <html lang="ja" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="ja" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="ja" class="no-js"> <!--<![endif]-->
<head>
	<meta charset="UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

	<title>ajax</title>
	<meta name="description" content="" />
	<meta name="author" content="Y.Nishimura@Office L / nishimuray@gmail.com" />

	<meta name="viewport" content="width=device-width, initial-scale=1.0" />

	<link rel="shortcut icon" href="/favicon.ico" />
	<link rel="apple-touch-icon" href="/apple-touch-icon.png" />

	<link rel="stylesheet" href="css/style.css?v=1" />

	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script>
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
	<script type="text/javascript" src="js/modernizr.js"></script>
	<script>!window.jQuery && document.write('<script src="js/jquery-1.6.1.js"><\/script>')</script>
	<script type="text/javascript" src="js/script.js"></script>
</head>
<body>

キーワード<input type="text" value="jQuery" id="k" />
<input type="button" id="search" value="ATND検索" />
<div id="log"></div>


<script type="text/javascript">
<!-- 
$(function() {

	$("#search").click(function(){
		console.log("Ajax start");
		v = $("#k").val();
		console.log("keywords:" + v);
		$.ajax({
			type: "GET",
			url: "http://api.atnd.org/events/?keyword=" + encodeURIComponent(v) + "&format=jsonp",
			dataType: "jsonp",
			cache:"false",
			success: function(msg){
				console.log(msg);
				console.log(msg['events'][0]['title']);
				var events = msg['events'];
				logs = $("#log");
				$.each(events,function(i,val){
					// console.log(i);
					// console.log(val);
					logs.append(val.started_at + ':<a href="' + val.event_url + '">' + val.title + '</a><br>');
				});
			},
			error: function(res){
				console.log("Ajax error");
				console.log(res);
			}
		});
	});
});
// -->
</script>

</body>
</html>
